<template>
      <el-input v-model="newComment" placeholder="输入你的留言...">
        <template #append>
          <el-button type="primary" @click="addComment">提交</el-button>
        </template>
      </el-input>
</template>

<script>
export default {
  data() {
    return {
      newComment:''
    }
  },
  methods: {
    addComment() {
      if (this.newComment) {
        this.$emit('new-comment', { name: this.$store.getters.name,text: this.newComment, time: Date.now() }); // 假设使用时间戳作为 ID
        this.newComment = ''; // 清空输入框
      }
    }
  }
}
</script>
